package com.dk.strategy;

import com.dk.config.CodePart;
import com.dk.model.AutoCodePart;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
@CodePart(partType = "NOWDATE")
public class NowDataStrategy implements CodeStrategyHandler {
    @Override
    public StringBuffer code(AutoCodePart part) {
        StringBuffer buffer = new StringBuffer();
        //拼接字符串,时间的话需要进行格式化
        String dateFormat = part.getDateFormat();
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        String formatDate = sdf.format(new Date());
        buffer.append(formatDate);
        return buffer;
    }
}
